package cn.jason.org.service.impl;

import cn.jason.basic.service.impl.BaseServiceImpl;
import cn.jason.basic.util.PageList;
import cn.jason.org.domain.DictionaryWord;
import cn.jason.org.mapper.DictionaryWordMapper;
import cn.jason.org.query.DictionaryWordQuery;
import cn.jason.org.service.IDictionaryWordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author xxx
 */
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DictionaryWordServiceImpl extends BaseServiceImpl<DictionaryWord> implements IDictionaryWordService {

    private final DictionaryWordMapper dictionaryWordMapper;

    public DictionaryWordServiceImpl(DictionaryWordMapper dictionaryWordMapper) {
        this.dictionaryWordMapper = dictionaryWordMapper;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(DictionaryWord dictionaryWord) {
        dictionaryWordMapper.save(dictionaryWord);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(DictionaryWord dictionaryWord) {
        dictionaryWordMapper.update(dictionaryWord);
    }

    @Override
    public PageList<DictionaryWord> queryPage(DictionaryWordQuery query) {
        Long total = dictionaryWordMapper.queryCount(query);
        List<DictionaryWord> rows = dictionaryWordMapper.queryData(query);
        return new PageList<>(total, rows);
    }


}
